import { reactive } from 'vue';

const state = reactive({
    notifications: [], // 存储通知数据的数组
});

const mutations = {
    addNotification(state, notification) {
        console.log('????????',state.notifications)
        state.notifications.push(notification);
    },
    deleteNotification(state, notificationId) {
        state.notifications = state.notifications.filter(item => item.id !== notificationId);
    },
};

const actions = {
    addNotification({ commit }, notification) {
        commit('addNotification', notification);
        console.log('!!!!!!!!!!',notification)
    },
    deleteNotification({ commit }, notificationId) {
        commit('deleteNotification', notificationId);
    },
};
const getters = {
    getNotifications: state => state.notifications
};

export default {
    namespaced: true,
    state,
    mutations,
    actions,
    getters
};